<template>
	<view class="root">
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">核减原因:</view>
			<butt class="flex7" height="50" style="margin: auto 10rpx;" bgc="#FF6B6B" :content="item.subtractResult == 0 ?'死亡':'迁出'"></butt>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">姓名:</view>
			<view class="flex7 text-left">{{item.name|| ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">出生年月:</view>
			<view class="flex7 text-left">{{this.$utiltg.dateDiff(item.birth)|| ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">性别:</view>
			<view class="flex7 text-left">{{item.gender == 1 ? '男':'女'}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">居住地址:</view>
			<view class="flex7 text-left">{{item.census|| ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">联系电话:</view>
			<view class="flex7 text-left">{{item.phone|| ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">身份证号:</view>
			<view class="flex7 text-left">{{item.idcard|| ''}}</view>
		</view>

		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">婚姻状态:</view>
			<view class="flex7 text-left">{{item.marriage || ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">民族:</view>
			<view class="flex7 text-left">{{item.nation || ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">户籍地址:</view>
			<view class="flex7 text-left">{{item.census|| ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view class="tr flex w8 text-left">
			<view class="flex3 blod">比对时间:</view>
			<view class="flex7 text-left">{{ toTime(item.subtractTime || item.matchTime)|| ''}}</view>
		</view>
		<cross-line class="divider"></cross-line>
		<view v-if="item.status == 0" class="tr flex w8 text-left">
			<view class="flex3 blod">核减结果:</view>
			<view class="flex7 text-left">
				<check-box :list="isAllow" @changeCheck="changeCheck"></check-box>
			</view>
		</view>

		<view>
			<view v-if="item.status == 0" style="margin: 15rpx auto; width: 140rpx; height: 10rpx;">
				<butt @clickButt="submit" :bgc="bgc" content="提交"></butt>
			</view>
		</view>
	</view>
</template>

<script>
	import butt from '@/components/ui/myButt.vue'
	import crossLine from '@/components/ui/tg-cross-line.vue'
	import checkBox from '@/components/ui/tg-checkbox.vue'
	export default {
		components: {
			butt,
			crossLine,
			checkBox,
		},
		data() {
			return {
				item: [],
				isOk: false,
				isAllow: [{
					content: '核减通过',
					check: false
				}, {
					content: '还原',
					check: true
				}]
			}
		},
		onLoad(e) {
			this.item = JSON.parse(e.item)
			console.log(this.item)
			console.log(e)
		},
		methods: {
			toTime(timep){
				console.log(timep)
				return this.$utiltg.dateDiff(timep)
			},
			async submit() {
				var item = this.item
				item.status = this.isOk?1:2
				console.log(item)
				var res = await this.$api.substractInfoWait(item)
				console.log(res)
				if(res.statusCode == 200){
					uni.showModal({
						title:'提示',
						content:'提交成功',
						success(){
							uni.navigateBack({
								
							})
						}
					})
				}else{
					uni.showModal({
						title:'提示',
						content:'网络繁忙，请稍后重试',
						success(){
							uni.navigateBack({
								
							})
						}
					})
				}
			},
			changeCheck(e) {
				console.log(e)
				this.isAllow = e
				var isOk = e[1].check ? false : true
				if (isOk) {
					this.bgc = '#33B0FF'
				} else {
					this.bgc = '#FF6B6B'
				}
				this.isOk = isOk
				return isOk
				// this.changeCheck({index})
			},
			// toDetail(){
			// 	this.$utiltg.navigateTo(`/pages/index/dynamic/subtractDetail/detail`);
			// }
		}
	}
</script>
<style scoped>
	.tr {
		line-height: 70rpx;
	}

	.choice::before {
		content: "";
		display: block;
		flex: 0.8;
		height: 1rpx;
	}

	.root::after {
		content: "";
		display: block;
		height: 100rpx;
		width: 750rpx;
	}
</style>
